<?php

class elFinderExProcessImage extends elFinderVolumeLocalFileSystem {
    public $config;
    
    public function exResize($path) {
        $this->imgLib = 'gd';

        if ($this->isValidSize($path)) {
            return $this->imgResize(
                $path,
                $this->config['max_width'],
                $this->config['max_height'],
                true
            );
        } else {
            return FALSE;
        }
    }

    /**
     * Check valid image size
     * @param string $path
     * @return boolean
     */
    protected function isValidSize($path) {
        $result = true;
        list($width, $height) = getimagesize($path);
        
        if ($width >= $height) { // is landscape
            if ($width <= $this->config['max_width'])
                $result = false;
        } else { //is portrait
            if ($height <= $this->config['max_height'])
                $result = false;
        }
        
        return $result;
    }
}